package com.misty.blog.controller.blogController;


import com.misty.blog.bean.param.guestbook.PubliashGKParam;
import com.misty.blog.service.GuestbookService;
import com.misty.common.bean.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 留言表 前端控制器
 * </p>
 *
 * @author cthulhu
 * @since 2022-12-15
 */
@RestController
@RequestMapping("/fore/guestbook")
public class GuestbookController {

    @Autowired
    private GuestbookService guestbookService;


    @GetMapping()
    public Result<?> page(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestParam(defaultValue = "") String type
    ) {
        return guestbookService.page(pageNum,pageSize,type);
    }

    @PostMapping("/publishGuestbook")
    @PreAuthorize("hasAuthority('fore/guestbook')")
    public Result<?> publishGuestbook(@RequestBody PubliashGKParam param) {
        return guestbookService.publishGuestbook(param);
    }

}

